import store from "@/store";

/**
 * 按钮权限指令
 *    <button v-auth="'base:sys:menu:add'"></button>
 * @param {*} el
 * @param {*} binding
 */
export function auth(el, binding) {
  // 1. 获取传递的 value 值
  const perm = binding.value;

  // 2. 获取当前用户的按钮权限集合
  const permissions = store.getters["user/permissions"];

  // 3. 判断是否在当前用户的权限集合中
  if (!permissions.includes(perm)) {
    // el.style.display = "none";
    // el.parentNode.removeChild(el);
    el.parentNode.remove(el);
    // console.log(el.parentNode);
  }
}
